package czk.concrent.review;

import java.util.concurrent.locks.LockSupport;

/**
 * 验证LockSupport的count计数器
 * 调用Unpark相当于给count++
 * park相当于给count--
 * count最大为1
 * 初始化线程的值为0
 * @Author:ChenZhangKun
 * @Date: 2020/6/22 23:28
 */
public class LockSupportDemo {
    public static void main(String[] args) {
        // 锁住本对象
        Thread thread = Thread.currentThread();
        LockSupport.unpark(thread);
        for (int i = 0; i < 3; i++) {
            System.out.print(i+" ");
        }
        LockSupport.park();
        for (int i = 3; i <6 ; i++) {
            System.out.print(i+" ");
        }
    }
}
